package com.ruoyi.rsikManage.task;

import com.ruoyi.rsikManage.service.ITAlarmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.stereotype.Component;

@Component
public class AlarmStatusRecordScheduler {
    @Autowired
    ITAlarmsService tAlarmsService;
    private String ground = "11";
    private String  undergroundKeyPositions = "12";
    private String  keyMinesUnderground = "13";
    //每分钟执行一次
    //@Scheduled(cron = "0 * * * * ?")
    private void recordAlarmStatusTask(){
        int unhandledAiAlarm_0 = tAlarmsService.countUnhandledAiAlarmInProvinceFileForToday(ground);
        int handlingAiAlarm_0 = tAlarmsService.countHandlingAiAlarmInProvinceFileForToday(ground);
        int handledAiAlarm_0 = tAlarmsService.countHandledAiAlarmInProvinceFileForToday(ground);
        int allAiAlarm_0 = tAlarmsService.countAllAiAlarmInProvinceFileForToday(ground);
        tAlarmsService.insertGroundAlarmSituationOfCurrent(unhandledAiAlarm_0, handledAiAlarm_0, allAiAlarm_0);
        int unhandledAiAlarm_1 = tAlarmsService.countUnhandledAiAlarmInProvinceFileForToday(undergroundKeyPositions);
        int handlingAiAlarm_1 = tAlarmsService.countHandlingAiAlarmInProvinceFileForToday(undergroundKeyPositions);
        int handledAiAlarm_1 = tAlarmsService.countHandledAiAlarmInProvinceFileForToday(undergroundKeyPositions);
        int allAiAlarm_1 = tAlarmsService.countAllAiAlarmInProvinceFileForToday(undergroundKeyPositions);
        tAlarmsService.insertUndergroundKeyPositionsAlarmSituationOfCurrent(unhandledAiAlarm_1, handledAiAlarm_1, allAiAlarm_1);
        int unhandledAiAlarm_2 = tAlarmsService.countUnhandledAiAlarmInProvinceFileForToday(keyMinesUnderground);
        int handlingAiAlarm_2 = tAlarmsService.countHandlingAiAlarmInProvinceFileForToday(keyMinesUnderground);
        int handledAiAlarm_2 = tAlarmsService.countHandledAiAlarmInProvinceFileForToday(keyMinesUnderground);
        int allAiAlarm_2 = tAlarmsService.countAllAiAlarmInProvinceFileForToday(keyMinesUnderground);
        tAlarmsService.insertKeyMinesUndergroundAlarmSituationOfCurrent(unhandledAiAlarm_2, handledAiAlarm_2, allAiAlarm_2);
    }
}
